package com.qcu.mapper;

import com.qcu.dto.chart.UserGoodCount;
import com.qcu.entity.Post;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author MyComputer
* @description 针对表【post】的数据库操作Mapper
* @createDate 2025-02-15 09:28:14
* @Entity com.qcu.entity.Post
*/
public interface PostMapper extends BaseMapper<Post> {

    @Select("SELECT u.username AS username, SUM(p.good) AS total_goods " +
            "FROM post p " +
            "LEFT JOIN user u ON p.user_id = u.id " +
            "GROUP BY u.id, u.username " +
            "ORDER BY total_goods DESC " +
            "LIMIT 5")
    List<UserGoodCount> getTopUserGoodCounts();
}




